/**
 @file ctc_cli_common.h

 @date 2020-06-19

 @version v2.0

  The file defines Macro, stored data structure for ctc sdk cli
*/
#ifndef _CTC_CLI_COMMON_H
#define _CTC_CLI_COMMON_H

#ifdef __cplusplus
extern "C" {
#endif

#define g_api_lchip     g_vty_client.api_lchip
#define g_api_ldev     g_vty_client.api_ldev

/* Common descriptions. */
#define CTC_CLI_SHOW_STR "Show running system information"
#define CTC_CLI_NO_STR      "Negate a command or set its defaults"
#define CTC_CLI_CLEAR_STR   "Clear functions"
#define CTC_CLI_ENABLE      "Enable functions"
#define CTC_CLI_DISABLE     "Disable functions"
#define CTC_CLI_SHOW_SYS_MEM_STR  "Memory information"
#define CTC_CLI_DEBUG_STR  "Debugging functions"
#define CTC_CLI_BOOL_VAR_STR  "Boolean variable"
#define CTC_CLI_AGING_STR     "Aging module"
#define CTC_CLI_LEARNING_AGING_STR "Learning and Aging module"
#define CTC_CLI_PARSER_STR "Parser module"
#define CTC_CLI_L2_HDR_STR "Layer 2 header of packet"

#define CTC_CLI_PORT_BITMAP_STR     "{pbmp0 PORT_BITMAP_0 | pbmp1 PORT_BITMAP_1 | pbmp2 PORT_BITMAP_2 | pbmp3 PORT_BITMAP_3 | pbmp4 PORT_BITMAP_4 | pbmp5 PORT_BITMAP_5 | pbmp6 PORT_BITMAP_6 | pbmp7 PORT_BITMAP_7 | pbmp8 PORT_BITMAP_8 | pbmp9 PORT_BITMAP_9 }"
                                                            
#define CTC_CLI_PORT_BITMAP_GET(port_bmp) \
{\
    index = CTC_CLI_GET_ARGC_INDEX("pbmp0");\
    if (index != 0xFF)\
    {\
        CTC_CLI_GET_UINT32("port bitmap 0", ((uint32*)port_bmp)[0], argv[index + 1]);\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("pbmp1");\
    if (index != 0xFF)\
    {\
        CTC_CLI_GET_UINT32("port bitmap 1", ((uint32*)port_bmp)[1], argv[index + 1]);\
    }\
}

#define CTC_CLI_ERROR_RETURN(op) \
    { \
        int32 rv = (op); \
        if (rv < 0) \
        { \
            ctc_cli_out("%% ret = %d\n", rv);\
            return CLI_ERROR;\
        } \
    }

#define CTC_CLI_LCHIP_ID_STR      "Local chip id"
#define CTC_CLI_LCHIP_ID_VALUE    "<0~chip_num-1> ,the lchip_num can be changed by ctc_chip_init() when you initialize SDK ,lchip_num default is 1."
#define CTC_CLI_UINT32_VAR_STR  "Uint32 variable"
#define CTC_CLI_UINT16_VAR_STR  "Uint16 variable"
#define CTC_CLI_UINT8_VAR_STR  "Uint8 variable"

#define CTC_CLI_PERF_TEST_STR "Performance test"

/*module*/
#define CTC_CLI_L2_M_STR "Layer 2 module"
#define CTC_CLI_MIRROR_M_STR "Mirror module"
#define CTC_CLI_PORT_M_STR "Port module"
#define CTC_CLI_VLAN_M_STR "VLAN module"
#define CTC_CLI_LINKAGG_M_STR "Linkagg module"
#define CTC_CLI_MEM_ALLOCM_STR "Memory Allocation module"
#define CTC_CLI_PDU_STR "Pdu module"

/* ACL -BEGIN-*/
#define CTC_CLI_ACL_STR              "ACL module"
#define CTC_CLI_ACL_GROUP_ID_STR     "ACL group id"
#define CTC_CLI_ACL_S_GROUP_ID_VALUE "ACL normal group id value"
#define CTC_CLI_ACL_GROUP_ID_VALUE   "<0-0xFFFFFFFF>"
#define CTC_CLI_ACL_GROUP_PRIO_STR   "ACL group priority"
#define CTC_CLI_ACL_GROUP_PRIO_VALUE "Group priority"
#define CTC_CLI_ACL_ENTRY_ID_STR     "ACL entry id"
#define CTC_CLI_ACL_ENTRY_ID_VALUE   "ACL entry id value"
#define CTC_CLI_ACL_ENTRY_PRIO_STR   "ACL entry priority"
#define CTC_CLI_ACL_ENTRY_PRIO_VALUE "<0-0xFFFFFFFF> :0 is lowest"

#define CTC_CLI_STATS_COLOR_STR          "Stats color "
#define CTC_CLI_STATS_COLOR_VALUE        "<0-1> 0 green, 1 not green. "
/*ACL -END-*/

/* QOS -BEGIN-*/
#define CTC_CLI_QOS_STR "QoS module"
#define CTC_CLI_QOS_RESRC_STR "QOS resource management"
#define CTC_CLI_QOS_PLC_STR "QoS policer"
#define CTC_CLI_QOS_DOMAIN_STR "QoS domain mapping"
#define CTC_CLI_QOS_TABLE_MAP_STR "QoS table mapping"
#define CTC_CLI_QOS_SHAPE_STR "QoS shaping"
#define CTC_CLI_QOS_SCHED_STR "QoS schedule"
#define CTC_CLI_QOS_STATS_STR "QoS statstics"
#define CTC_CLI_QOS_QUEUE_STR "Queue id"
#define CTC_CLI_QOS_QUEUE_VAL "Queue ID"
#define CTC_CLI_QOS_SERVICE_STR "Service identification"
#define CTC_CLI_QOS_SERVICE_VAL "Service id value"
#define CTC_CLI_QOS_FLOW_PLC_STR "QoS flow policer"
#define CTC_CLI_QOS_FLOW_PLC_VAL "<1-0xFFFF>"
#define CTC_CLI_QOS_VLAN_PLC_STR "QoS vlan policer"
#define CTC_CLI_QOS_VLAN_PLC_VAL "Vlan id"
#define CTC_CLI_QOS_COPP "Control Plane Policing"
#define CTC_CLI_QOS_PLC_CIR_STR "Config CIR (Commit Information Rate)"

#define CTC_CLI_QOS_PLC_EIR_STR "Config EIR (Excess Information Rate)"

#define CTC_CLI_QOS_PLC_PIR_STR "Config PIR (Peak Information Rate)"

#define CTC_CLI_QOS_PLC_CBS_STR "Config CBS (Commit Burst Size)"
#define CTC_CLI_QOS_PLC_EBS_STR "Config EBS (Excess Burst Size)"
#define CTC_CLI_QOS_PLC_PBS_STR "Config PBS (Peak Burst Size)"
#define CTC_CLI_QOS_SHAPE_CBS_STR "CBS value unit bytes"
#define CTC_CLI_QOS_SHAPE_PBS_STR "PBS value unit bytes"
#define CTC_CLI_QOS_WDRR_WEIGHT_VAL "Weight value"
#define CTC_CLI_QOS_CLASS_VAL "Class value"
/* QOS -END-*/

/* Stats -BEGIN- */
#define CTC_CLI_STATS_STR      "Statistics"
#define CTC_CLI_STATS_ID_DESC  "Stats id"
#define CTC_CLI_STATS_ID_VAL   "<0-0xFF>, 0 means invalid"
/* Stats -END- */

#define CTC_CLI_CPU_SAMPLE_M_STR "Cpu sample module"
#define CTC_CLI_DMA_M_STR "Dma module"
#define CTC_CLI_CHIP_AGT_STR "Chip Agent module"
#define CTC_CLI_PACKET_M_STR "Packet module"
#define CTC_CLI_PACKET_SAMPLE_M_STR "Sample Packet module"

#define CTC_CLI_LOG_FILE   "Log file name "

/* VLAN -BEGIN- */
#define CTC_CLI_VLAN_RANGE_GRP_ID_VALUE "<0-3>"
#define CTC_CLI_TAG_OP_DESC "0:NONE(Do nothing), 1:REP_OR_ADD (Replace for tagged, add for untagged. Rep or add is auto-ajusted), 2:APPEND(add for untagged, even for tagged ), 3:DELETE (delete tagged), 4:REPLACE(Replace for tagged, do nothing for untagged.), 5:DO NOTHING"
#define CTC_CLI_TAG_SL_DESC "0:AS_RECEIVE(Select packet's vid|cos), 1:ALTERNATE(Select the other tag's vid|cos), 2:NEW (Select the tag user assigned), 3:Default (Select the default vid|cos)"

/* VLAN -END- */

/*parameter*/
#define CTC_CLI_L2_PDU_STR "Layer2 PDU"
#define CTC_CLI_L3_PDU_STR "Layer3 PDU"
#define CTC_CLI_ADD "Add operation"
#define CTC_CLI_REMOVE "Remove operation"
#define CTC_CLI_MAC_DESC "MAC address"
#define CTC_CLI_MACDA_DESC "MAC DA address"
#define CTC_CLI_MACSA_DESC "MAC SA address"
#define CTC_CLI_MAC_FORMAT "MAC address in HHHH.HHHH.HHHH format"
#define CTC_CLI_MAC_MASK_FORMAT "MAC mask in HHHH.HHHH.HHHH format"
#define CTC_CLI_IPV4_FORMAT "IPv4 address in A.B.C.D format"
#define CTC_CLI_IPV4_MASK_FORMAT "IPv4 mask in A.B.C.D format"
#define CTC_CLI_IPV4_MASK_LEN_FORMAT "The length of Ipv4 mask <0-32>"
#define CTC_CLI_IPV6_FORMAT "IPv6 address in X:X::X:X format"
#define CTC_CLI_IPV6_MASK_FORMAT "IPv6 mask in X:X::X:X format"
#define CTC_CLI_IPV6_MASK_LEN_FORMAT "The length of Ipv6 mask <0-128>"
#define CTC_CLI_GPORT_ID_WITHOUT_LINKAGG_DESC   "type(4bit)|reserve(10bit)|lport_ext(3bit) | gchip(7bit) | lport (8bit)"
#define CTC_CLI_FID_ID_DESC "Defined by user, default max value is 127"
#define CTC_CLI_L2PDU_MACDA_48BIT_ENTRY_INDEX "<38-53>"
#define CTC_CLI_L2PDU_PER_PORT_ACTION_INDEX "<0-53>"
#define CTC_CLI_L3PDU_ENTRY_INDEX "<38-53>"
#define CTC_CLI_L3PDU_GLOBAL_ACTION_INDEX "<0-53>"
#define CTC_CLI_L2PDU_L3TYPE_ACTION_INDEX "<38-53>"
#define CTC_CLI_IPMC_M_STR "IPMC module"
#define CTC_CLI_IPMC_GROUP_DESC         "IP multicast group"
#define CTC_CLI_GLOBAL_MCASTGRP_ID_DESC "Mcast Group ID,it is allocated in platform adaption Layer"
#define CTC_CLI_VRFID_DESC "VRF id of route"
#define CTC_CLI_VRFID_ID_DESC "Vrfid Value"
#define CTC_CLI_IPMC_MEMBER_DESC  "Member of the ipmc group"

#define CTC_CLI_VLAN_DESC "VLAN"
#define CTC_CLI_VLAN_RANGE_DESC "<1-4095>"
#define CTC_CLI_VLAN_RANGE_MASK "<0-0xFFF>"
#define CTC_CLI_COS_RANGE_DESC  "<0-7>"
#define CTC_CLI_COS_RANGE_MASK  "<0-7>"
#define CTC_CLI_CFI_RANGE_DESC  "<0-1>"
#define CTC_CLI_EXP_RANGE_DESC  "<0-7>"
#define CTC_CLI_FID_DESC "Forwarding ID"
#define CTC_CLI_GPHYPORT_ID_DESC                "type(4bit)|reserve(10bit)|lport_ext(3bit) | gchip(7bit, 0x1F for linkagg) | lport/linkagg_id (8bit)"
#define CTC_CLI_GPORT_ID_DESC                    CTC_CLI_GPHYPORT_ID_DESC
#define CTC_CLI_GPORT_DESC "Global port"
#define CTC_CLI_SECURITY_STR "Security module"
#define CTC_CLI_PORT_BITMAP_DESC "Bitmap of ports"
#define CTC_CLI_PORT_BITMAP_VALUE_DESC "Bitmap value"

#define CTC_CLI_QOS_PLC_CIR_VAL "Rate in kbps/pps"
#define CTC_CLI_QOS_PLC_EIR_VAL "Rate in kbps/pps"
#define CTC_CLI_QOS_PLC_PIR_VAL "Rate in kbps/pps"
#define CTC_CLI_QOS_PLC_CBS_VAL "Burst size in kb/pkt, default is 64"
#define CTC_CLI_QOS_PLC_EBS_VAL "Burst size in kb/pkt, default is 64"
#define CTC_CLI_QOS_PLC_PBS_VAL "Burst size in kb/pkt, default is 64"
#define CTC_CLI_NH_DSNH_TUNNEL_DSCP_DESC "Dscp"
#define CTC_CLI_NH_DSNH_TUNNEL_DSCP_VAL "Dscp value"
#define CTC_CLI_INTERNAL_PORT_RANGE  "Internal port range value"
#define CTC_CLI_SYNC_ETHER_M_STR "SyncE module"
#define CTC_CLI_QOS_DOMAIN_VALUE    "Domain value"
#define CTC_CLI_PRIORITY_VALUE       "Priority value"


#define CTC_CLI_ACL_KEY_FIELED_GREP_NUM 16
#define CTC_CLI_ACL_KEY_ARG_CHECK(arg_cnt,arg_num,p_field) \
        arg_cnt++; \
        if (p_field && arg_cnt < arg_num) p_field++;\
        if(arg_cnt > arg_num) return CTC_E_INVALID_PARAM;

extern const char *ctc_get_error_desc(int32 error_code);
#ifdef __cplusplus
}
#endif
#endif /* _CTC_CLI_COMMON_H */

